package user

import "time"

type UpdateUserReq struct {
	Nickname    string `json:"nickname"`     // 昵称
	Avatar      string `json:"avatar"`       // 头像
	Birthday    int64  `json:"birthday"`     // 生日
	Year        int64  `json:"year"`         // 年
	Month       int64  `json:"month"`        // 月
	Day         int64  `json:"day"`          // 日
	Province    string `json:"province"`     // 省
	City        string `json:"city"`         // 市
	Area        string `json:"area"`         // 区|县
	Gender      int64  `json:"gender"`       // 性别 1男 2女
	Income      string `json:"income"`       // 收入
	Education   string `json:"education"`    // 学历
	Occupation  string `json:"occupation"`   // 职业
	Height      int64  `json:"height"`       // 身高
	Weight      int64  `json:"weight"`       // 体重
	MainPhoto   string `json:"main_photo"`   // 主图
	LivingPhoto string `json:"living_photo"` // 生活照
}

func (req *UpdateUserReq) GetLiving() string {
	if req.LivingPhoto == "" {
		return "[]"
	}

	return req.LivingPhoto
}

func (req *UpdateUserReq) GetUserUpdates() map[string]interface{} {
	return map[string]interface{}{
		"nickname":    req.Nickname,
		"avatar":      req.Avatar,
		"birthday":    req.Birthday,
		"year":        req.Year,
		"month":       req.Month,
		"day":         req.Day,
		"province":    req.Province,
		"city":        req.City,
		"area":        req.Area,
		"gender":      req.Gender,
		"income":      req.Income,
		"education":   req.Education,
		"occupation":  req.Occupation,
		"height":      req.Height,
		"weight":      req.Weight,
		"update_time": time.Now().Unix(),
	}
}

type UpdateUserByFieldReq struct {
	Field   string `json:"field" binding:"required"`
	Message string `json:"message" binding:"required"`
}

type UpdateUserDetailReq struct {
	Birthday     int64  `json:"birthday"`      // 生日
	Year         int64  `json:"year"`          // 年
	Month        int64  `json:"month"`         // 月
	Day          int64  `json:"day"`           // 日
	Province     string `json:"province"`      // 省
	City         string `json:"city"`          // 市
	Area         string `json:"area"`          // 区|县
	HomeProvince string `json:"home_province"` // 家 省
	HomeCity     string `json:"home_city"`     // 家 市
	HomeArea     string `json:"home_area"`     // 家 区|县
	Income       string `json:"income"`        // 收入
	Height       int64  `json:"height"`        // 身高
	Occupation   string `json:"occupation"`    // 职业
}

func (req *UpdateUserDetailReq) GetUserUpdates() map[string]interface{} {
	return map[string]interface{}{
		"birthday":      req.Birthday,
		"year":          req.Year,
		"month":         req.Month,
		"day":           req.Day,
		"province":      req.Province,
		"city":          req.City,
		"area":          req.Area,
		"home_province": req.HomeProvince,
		"home_city":     req.HomeCity,
		"home_area":     req.HomeArea,
		"income":        req.Income,
		"height":        req.Height,
		"occupation":    req.Occupation,
		"update_time":   time.Now().Unix(),
	}
}
